﻿<UserControl x:Class="Cirrostrata.CycleList.CaliburnTest.Views.ComplexView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cl="clr-namespace:Cirrostrata.CycleList;assembly=Cirrostrata.CycleList"
    xmlns:inf="clr-namespace:Cirrostrata.CycleList.CaliburnTest.Infrastructure"
    xmlns:cal="clr-namespace:Caliburn.PresentationFramework;assembly=Caliburn.PresentationFramework"
    xmlns:model="clr-namespace:Cirrostrata.CycleList.Model;assembly=Cirrostrata.CycleList.Model"
    >

    <UserControl.Resources>
        <inf:EnumToResourceConverter x:Key="resConverter" />
        <model:EquipmentStatusBindingSource x:Key="equipmentStatusSource"/>
    </UserControl.Resources>

    <DockPanel>
        <DockPanel.LayoutTransform>
            <ScaleTransform ScaleX="2" ScaleY="2"/>
        </DockPanel.LayoutTransform>

        <StackPanel DockPanel.Dock="Bottom">
            <TextBlock Text="{Binding Path=CurrentStatus}"/>
            <Button Content="Simple" cal:Message.Attach="Action SwitchToSimple" Width="60" HorizontalAlignment="Center" />
        </StackPanel>

        <ListBox ItemsSource="{Binding Path=AllEquipment}" HorizontalContentAlignment="Stretch">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        
                        <TextBlock Grid.Column="0" Text="{Binding Path=Name}" />
                        
                        <cl:CycleList 
                            Grid.Column="1" 
                            ItemsSource="{StaticResource equipmentStatusSource}" 
                            SelectedItem="{Binding Path=Status, Mode=TwoWay}">

                            <cl:CycleList.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock>
                                        <Image Source="{Binding Converter={StaticResource resConverter}}" Width="12" Height="12" /> 
                                        <TextBlock Text="{Binding}"/>
                                    </TextBlock>
                                </DataTemplate>
                            </cl:CycleList.ItemTemplate>
                            
                        </cl:CycleList>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </DockPanel>

</UserControl>
